home *** CD-ROM | disk | FTP | other *** search
- /*
- * FormatNewsHeader.ced
- *
- * Find the next header of a news article (starting with
- * "Article:") and format it in a nice way, stripping all
- * unnecessary lines like "Path", "Nntp-Posting-Host:" etc.
- *
- * Example:
- *
- * Subject: Re: Byte's Amiga 4000 review...
- *
- * From: andy@cbmvax.commodore.com (Andy Finkel)
- * Organization: Flying Cat, Inc.
- * Date: 11 Jan 93 15:29:12 GMT
- *
- * Newsgroups: comp.sys.amiga.advocacy
- * Article: 5376 of comp.sys.amiga.advocacy
- * Message-ID: <38461@cbmvax.commodore.com>
- *
- * Known Problem:
- *
- * Cannot handle keywords with more than one line of text.
- *
- * Author: Stefan Winterstein (winter@cs.uni-sb.de)
- * Status: Public Domain
- *
- */
-
-
- LF = '0A'X
- options results /* Allow CygnusEd to pass status variables */
-
- address 'rexx_ced' /* Tell ARexx to talk to CygnusEd */
-
- signal on error
- signal on syntax
-
- status 69
- if (result ~= -1) then 'mark block' /* turns block marking off */
-
- /*
- * Find the beginning of the next header.
- */
- 'search for' 'rticle:' FALSE FALSE TRUE FALSE
- if ~result then do
- okay1 "Could not find 'Article:'"
- exit
- end
- 'beg of line'
- 'mark location' 3
-
- /*
- * Now read in line by line until no ':' can be found. This is
- * considered the end of the header.
- * Each line is stored in 'header.keyword', where 'keyword' is
- * the word before the colon.
- */
- do until (dppos == 0)
- status 55
- line = result /* current line of text */
- dppos = index(line, ':')
-
- if (dppos ~= 0) then do
- keyword = left(line, dppos-1)
- /* Avoid syntax problems with '-' in 'Message-ID' */
- keyword = translate(keyword, '_', '-')
-
- interpret header.keyword "= line"
-
- 'down'
- end
- end
-
- /*
- * Cut the header.
- */
- 'mark block'
- 'jump to mark' 3
- 'cut block'
-
- /*
- * Now insert the lines we want (if they exist).
- */
- if header.subject ~= 'HEADER.SUBJECT' then
- 'text' header.subject
- if header.summary ~= 'HEADER.SUMMARY' then
- 'text' header.summary
- if header.keywords ~= 'HEADER.KEYWORDS' then
- 'text' header.keywords
- 'text' LF
- if header.from ~= 'HEADER.FROM' then
- 'text' header.from
- if header.organization ~= 'HEADER.ORGANIZATION' then
- 'text' header.organization
- if header.date ~= 'HEADER.DATE' then
- 'text' header.date
- 'text' LF
- if header.newsgroups ~= 'HEADER.NEWSGROUPS' then
- 'text' header.newsgroups
- if header.article ~= 'HEADER.ARTICLE' then
- 'text' header.article
- if header.message_id ~= 'HEADER.MESSAGE_ID' then
- 'text' header.message_id
- 'text' LF
-
- /*
- * Bye.
- */
- exit
-
- error:
- okay1 "Error in line" sigl LF||"Error code" rc
- syntax:
- okay1 "Syntax Error in line" sigl LF||"Error code" rc
-